﻿using Hardware.Reactor.Base.Model;
using Hardware.Reactor.Base.Setting;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Hardware.Reactor.Base
{
    /// <summary>
    /// 电机控制：运动控制器，反应釜的搅拌电机、控制转速
    /// </summary>
    public interface IMotionController
    {
        /// <summary>
        /// 表示是否初始化
        /// </summary>
        bool Initialized { get; }
        /// <summary>
        /// 连接状态
        /// </summary>
        bool Connected { get; }
        /// <summary>
        /// 运行消息
        /// </summary>
        string Message { get; }
        /// <summary>
        /// 运行消息的观察者
        /// </summary>
        IObservable<string> MessageObservable { get; }
        
        /// <summary>
        /// 通讯模式
        /// </summary>
        ConnectionMode ConnectionMode { get; }
        /// <summary>
        /// 初始化
        /// </summary>
        /// <param name="config"></param>
        /// <param name="connectionMode"></param>
        /// <returns></returns>
        bool Init(IReactorConfigProvider config, ConnectionMode connectionMode = ConnectionMode.串口);
        /// <summary>
        /// 检测连接状态 
        /// </summary>
        /// <returns></returns>
        bool CheckConnection();
        /// <summary>
        /// 写入数据
        /// </summary>
        /// <param name="data"></param>
        /// <returns></returns>
        bool Send(byte[] data);
        /// <summary>
        /// 开启机械电机
        /// </summary>
        /// <param name="motor"></param>
        /// <returns></returns>
        bool StartMachineMotor(MotorModel motor);
        /// <summary>
        /// 停止机械电机
        /// </summary>
        /// <param name="motor"></param>
        /// <returns></returns>
        bool StopMachineMotor(MotorModel motor);
        /// <summary>
        /// 开启磁力电机
        /// </summary>
        /// <param name="motor"></param>
        /// <returns></returns>
        bool StartMagneticMotor(MotorModel motor);
        /// <summary>
        /// 停止磁力电机
        /// </summary>
        /// <param name="motor"></param>
        /// <returns></returns>
        bool StopMagneticMotor(MotorModel motor);
        /// <summary>
        /// 关闭硬件
        /// </summary>
        void Close();

        
    }
}
